#include <stdio.h>
#include <string.h>
int main()
{
	int n,i=0,j,day,year;
	char month[10];
	char td[20][9]={"imix","ik","akbal","kan","chicchan",
		"cimi","manik","lamat","muluk","ok","chuen","eb",
		"ben","ix","mem","cib","caban","eznab","canac","ahau"};
	char hm[19][7]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen",
		"yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
	scanf("%d", &n);
	int num[n];
	while(i<n)
	{
		scanf("%d. %s %d", &day, month, &year);
		j=0;
		while (j<19)
		{
			if (strcmp(month,hm[j]) == 0)
			{
				num[i] = day + j * 20 + year * 365;
			}
			j++;
		}
		i++;
	}
	i=0;
	printf("%d\n", n);
	while (i<n)
	{
		printf("%d\n", num[i]);
		printf("%d %s %d\n", num[i]%13+1, td[num[i]%20], num[i]/260);
		i++;
	}
	return 0;
}
